// var xx = preferences.rulerUnit;

// var layerRef = app.activeDocument.artLayers.getByName("bottom"); 
// layerRef.allLocked = true;

function getCurrentBrushInfo() { 

    var brsh = {}; 

    var ref = new ActionReference(); 

    ref.putEnumerated(charIDToTypeID("capp"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt")); 

    var currentBrush = executeActionGet(ref).getObjectValue(stringIDToTypeID("currentToolOptions")).getObjectValue(charIDToTypeID('Brsh')); 

 

    brsh.diameter = currentBrush.getDouble(charIDToTypeID('Dmtr')); 

    // brsh.hardness = currentBrush.getDouble(charIDToTypeID('Hrdn')); 

    brsh.angle = currentBrush.getDouble(charIDToTypeID('Angl')); 

    brsh.roundness = currentBrush.getDouble(charIDToTypeID('Rndn')); 

    brsh.spacing = currentBrush.getDouble(charIDToTypeID('Spcn')); 

    return brsh
}

function setCurrentBrushSize(_size) {

    var desc1 = new ActionDescriptor();   

    var ref1 = new ActionReference();   

    ref1.putEnumerated(charIDToTypeID('Brsh'), charIDToTypeID('Ordn'), charIDToTypeID('Trgt'));   

    desc1.putReference(charIDToTypeID('null'), ref1);   

    var desc2 = new ActionDescriptor();   

    desc2.putUnitDouble(stringIDToTypeID("masterDiameter"), charIDToTypeID('#Pxl'), _size);   

    desc1.putObject(charIDToTypeID('T   '), charIDToTypeID('Brsh'), desc2);   

    executeAction(charIDToTypeID('setd'), desc1, DialogModes.NO);   

    return _size;
}


// $.level = 2;
// debugger; 

// brsh = getCurrentBrushInfo();
//
// var _size = brsh.diameter+1;
//
// setCurrentBrushSize(backgroundColor.rgb.blue);


